# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=phonegap
pkgver=9.0.0
pkgrel=2
pkgdesc="PhoneGap command-line interface and node.js library"
arch=('loong64' 'x86_64')
url="https://github.com/phonegap/phonegap-cli"
license=('Apache')
depends=('cordova' 'nodejs-nopt' 'semver')
makedepends=('npm' 'python')
install=${pkgname}.install
source=(https://registry.npmjs.org/$pkgname/-/$pkgname-$pkgver.tgz)
noextract=($pkgname-$pkgver.tgz)
sha512sums=('072b05307843eb42dfbf1a7c58f0a9dd43eb29ef5ef718e99771e741b78dd10c19d0d5704892b1fd4c1068a09ab8a1f1a7680241283cf31afa1e573aca75dea2')

package() {
  npm install -g --prefix "$pkgdir"/usr "$srcdir"/$pkgname-$pkgver.tgz

  # Non-deterministic race in npm gives 777 permissions to random directories.
  # See https://github.com/npm/npm/issues/9359 for details.
  chmod -R u=rwX,go=rX "$pkgdir"

  # npm installs package.json owned by build user
  # https://bugs.archlinux.org/task/63396
  chown -R root:root "$pkgdir"

  # Delete npm installed pyc files
  find "$pkgdir" -name "*.pyc" -delete

  # Experimental dedup
  rm -r "$pkgdir"/usr/lib/node_modules/$pkgname/node_modules/{,.bin/}cordova
  rm -r "$pkgdir"/usr/lib/node_modules/$pkgname/node_modules/{,.bin/}nopt
  rm -r "$pkgdir"/usr/lib/node_modules/$pkgname/node_modules/{,.bin/}semver
}

# vim:set ts=2 sw=2 et:
